

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>Grade Bay</title>
		<link rel="stylesheet" href="gui.css" type="text/css" />
		<!--[if IE 7]>
			<link rel="stylesheet" href="css/ie7.css" type="text/css" />
		<![endif]-->
	</head>
	<body>
		<div class="page">
			<div class="header">
				<a href="index.php" id="logo"><img src="images/gradeBaylogo.png" width="330" height="79" alt=""/></a>
				<ul>
					<li class="selected"><a href="">EDIT TEACHER</a></li>
					
				
				</ul>
			</div>
			<div class="body">
                         
				  <?php

                                    /*
                                    * To change this template, choose Tools | Templates
                                    * and open the template in the editor.
                                    */
                                        include 'PHPClasses/DBAccess.php';
                                        include 'PHPClasses/TeacherDBAccess.php';
                                        include 'PHPClasses/Teacher.php';
                                        
                                        error_reporting(E_ERROR | E_PARSE);  
                                         if ($_POST['submitted']==1)
                                            { 

                                                $DBAccess=new TeacherDBAccess();
                                                $Teacher=new Teacher();
                                                $Teacher->setIdTeacher($_POST["teacherID"]);
                                                $Teacher->setTeacherName($_POST["teacherName"]);
                                                $levels=$_POST["level"];
                                                $Teacher->setLevels($levels);

                                                $errormsg=$DBAccess->validate($Teacher,TRUE);

                                                if ($errormsg){ 
                                                    header("Location: http://localhost/paragox-infinity-introse/editTeacher.php?error=".$errormsg."&teacherID=".$Teacher->getIdTeacher());
                                                    
                                                    
                                                }
                                                else
                                                {
                                                    $DBAccess->updateDB($Teacher);
                                                    
                                                     echo "<script> 
                                                    if(confirm('Teacher updated! Forgot something?')){
                                                            window.location='http://localhost/paragox-infinity-introse/editTeacher.php?teacherID=".$Teacher->getIdTeacher()."';
                                                    }

                                                    else{
                                                        window.location='http://localhost/paragox-infinity-introse/viewTeachers.php';
                                                        }   

                                                    </script>"; 
                                                    
                                                     
                                                }
                                            }

                                    ?>
                             
				
			</div>
			
		</div>
	</body>
</html>  